﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using King.Engine.Content;
using Microsoft.Xna.Framework;

namespace King.Engine.Tester
{
    public class MainLevelScheme : LevelScheme<GameActivity>
    {
        
        #region Fields

        private static Dictionary<string, BuildLevelElement> _builders = new Dictionary<string, BuildLevelElement>()
        {
            {"BlockRange", BuildBlockRange},
            {"PlayerSpawn", BuildPlayerSpawn},
        };

        #endregion


        #region Constructor

        public MainLevelScheme()
            : base(_builders)
        {

        }

        #endregion


        #region Private Methods

        private static void BuildPlayerSpawn(GameActivity activity, Dictionary<string, string> attributes)
        {
            int x = int.Parse(attributes["x"]);
            int y = int.Parse(attributes["y"]);

            activity.PlayerSpawn = new Point(x, y);
        }

        private static void BuildBlockRange(GameActivity activity, Dictionary<string, string> attributes)
        {
            int startX = int.Parse(attributes["x"]);
            int startY = int.Parse(attributes["y"]);
            int w = int.Parse(attributes["width"]);
            int h = int.Parse(attributes["height"]);

            for (int col = 0; col < w; col++)
            {
                int x = startX + col * 100;
                for (int row = 0; row < h; row++)
                {
                    int y = startY + row * 100;

                    Block block = new Block(x, y);
                    activity.AddGameObject(block);
                }
            }

        }


        #endregion

    }
}
